import service from "../request/service.js";

const http = {
	// get 请求的参数名是 params
	get(url, param) {
		const config = {
			method: 'GET',
			params: param ? param : undefined,
			url: url
		};

		return service(config);
	},

	// post 请求的参数名是 data
	post(url, param) {
		const config = {
			method: 'POST',
			data: param ? param : undefined,
			url: url
		};

		return service(config);
	},

	put(url, param) {
		const config = {
			method: 'PUT',
			params: param ? param : undefined,
			url: url
		};

		return service(config);
	},

	delete(url, param) {
		const config = {
			method: 'DELETE',
			params: param ? param : undefined,
			url: url
		};

		return service(config);
	}
};

export default http;